<!DOCTYPE HTML>
<html lang="en-US">

<link rel="stylesheet" href="../../css/style.css">
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport"
	content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<!-- 引入Vue -->
<script src="../js/vue.min.js"></script>
<!-- 引入axios -->
<script type="text/javascript"
	src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
<!-- 引入layui -->
<link rel="stylesheet" href="../../webjars/layui/2.5.6/css/layui.css"
	type="text/css">
<script type="text/javascript"
	src="../../webjars/layui/2.5.6/layui.all.js"></script>
</head>
 	<!-- 配置文件 -->
    <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" charset="utf-8" src="editor_api.js"></script>
       
<body>
	<div id="block"
		style="width: 1000px; height: 560px; max-height: 900px; margin: auto">
		<div class="main-container">
			<div class="left-container">

				<div class="profile">
					<img :src="user.image" alt="user-avatar" />
					<p class="username">{{user.name}}</p>
				</div>
			</div>
			<script type="text/javascript">
	
		
		
		</script>

			<div class="right-container" style="padding: 10px 5px;">
				<div class="layui-form-item">
					<label class="layui-form-label">标题</label>
					<div class="layui-input-block">
						<input v-model="title" type="text" name="title" lay-verify="title"
							autocomplete="off" placeholder="请输入标题" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">类别</label>
					<div class="layui-input-inline">
						<select v-model="type" :value="type" name="quiz1">
							<option v-for="(tp,i) in quiz1">{{tp.type}}</option>
						</select>
					</div>
				</div>



				<div class="layui-form-item">
					<label class="layui-form-label">标签</label>
					<div class="layui-input-inline">
						<select v-model="log" :value="log" name="quiz2">
							<option v-for="lg in quiz2" >{{lg.log}}</option>
						</select>
					</div>
				</div>


			</div>

		</div>

		<div id="edtr"
			style="width: 1000px; height: 1200px; max-height: 900px; margin: auto">
		 <script id="container" name="content" type="text0ain" style="height:1200px;"></script>
			<button @click="submit()" id="test01" name="uText">获取文本</button>
			<button id="test02" name="uHtml" @click="submit">查看html</button>
		</div>
	</div>
	<script type="text/javascript">
    var ue = UE.getEditor('container');
    var btn = document.getElementById("test01");
    var btn1 = document.getElementById("test02");
   
    var v1 = new Vue({
    	el:"#block",
    	data:{
    		user:[],
    		test:"",
    		title:"",
    		quiz1:[],
    		quiz2:[],
    		type:"",
    		log:"",
    	},
    	methods:{
    	
    		submit(){
    			this.test = ue.getContent();
    			var params = new URLSearchParams();
				params.append("content",this.test);
				params.append("type",this.type);
				params.append("log",this.log);
				params.append("title",this.title);
    			axios.post("../../artical/getData.s",params).then(res=>{
    				if(res.data.code==1){
    					alert(res.data.msg);
    			location.href = "../index.html";
    				}else{
    					alert(res.data.msg);
    				}
    			})
    			
    	
    		}
    	},
    	created(){
			axios.get("../../top.s").then(res=>{
				this.user = res.data;
				
			}),
			axios.get("../../artical/getType.s").then(res=>{
				this.quiz1 = res.data;
					
				}),
			axios.get("../../artical/getLog.s").then(res=>{
				this.quiz2 = res.data;
					})
			
		}
    })
</script>


</body>
</html>
